//
//  MainViewController.h
//  SlashEM
//
//  Created by dirk on 12/30/09.
//  Copyright 2009 Dirk Zimmermann. All rights reserved.
//

//  This file is part of Slash'EM.
//
//  Slash'EM is free software: you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation, version 2 of the License only.
//
//  Slash'EM is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with Slash'EM.  If not, see <http://www.gnu.org/licenses/>.

#import <UIKit/UIKit.h>
#import "MainView.h"
#import "ZDirection.h"

@class NhYnQuestion;
@class ZTouchInfoStore;
@class ZStack;
@class NhMenuWindow;
@class NhWindow;
@class NhCommand;
@class ActionBar;

@interface MainViewController : UIViewController <UITextViewDelegate, UITextFieldDelegate> {
	
	NhYnQuestion *currentYnQuestion;
	ZTouchInfoStore *touchInfoStore;
	NSArray *commands;
	ZStack *overlayViews;
	CGFloat initialDistance;
	ZStack *actionBars;
	
	// for detecting taps on the hero
	CGRect mapCenter;
	
	// maximum duration between two taps to be counted as double tap
	float doubleTapDuration;
	
}

@property (nonatomic, assign) BOOL actionBarHidden;
@property (nonatomic, readonly) ActionBar *mainActionBar;

+ (MainViewController *) instance;

// called from view when it's ready

- (void)viewIsSetup;

// window API

// gets called when core waits for input
- (void)refreshAllViews;
- (void)refreshMessageView;
- (void)handleDirectionQuestion:(NhYnQuestion *)q;
- (void)showYnQuestion:(NhYnQuestion *)q;
- (void)displayBlockingString:(NSString *)text;
- (void)displayBlockingWindow:(NhWindow *)w;
- (void)displayWindow:(NhWindow *)w;
- (void)cliparoundX:(int)x y:(int)y;
- (void)showMenuWindow:(NhMenuWindow *)w;
- (void)getLine;
- (void)showExtendedCommands;

// remove overlay and send -1 to core
- (void)cancelNhActionView:(id)sender;

// just remove overlay (was pure GUI)
- (void)cancelActionView:(id)sender;

- (void)showContextCommands;

// touch handling

- (int)keyFromDirection:(e_direction)d;

// commands

- (void)showKeyboardAction:(id)sender;
- (void)commandAction:(NhCommand *)cmd;

// util

- (void)hideKeyboard;
- (void)popOverlayView:(OverlayView *)v;
- (void)disableInputs;
- (void)pushActions:(NSArray *)actions;
- (ActionBar *)mainActionBar;

// called from other controls
- (void)removeActionBar:(ActionBar *)ab;

@end
